# coding=utf-8
import requests
import hashlib   
import time



appkey = '23656735'
#secret = '91400648c84ddd33f32dd9181d5f14c8'
sessionkey = '620281281f27bfa430e3ZZcc4f438a274819675e989696e552522139'
format1 = 'json'
method = 'taobao.picture.upload'
sign_method = 'md5'

timestamp = time.localtime(time.time())
timestamp = time.strftime("%Y-%m-%d %H:%M:%S", timestamp)

v = '2.0'
picture_category_id = 0
with open('timg.jpeg', 'rb') as f:
    img = f.read()

image_input_title = 'shiyan.jpg'
sign ='appkey'+appkey+'format'+format1+'image_input_title'+ image_input_title+'method'+method+'picture_category_id'+str(picture_category_id)+'sessionkey'+sessionkey+'sign_method'+sign_method+'timestamp'+timestamp+'v'+v
m2 = hashlib.md5()   
sign = m2.update(sign)


data = {
        'appkey':appkey,
        'format':format1,
        'image_input_title':image_input_title,
        #'img':img,
        'method':method,
        'picture_category_id':picture_category_id,
        'sessionkey':sessionkey,
        'sign_method':sign_method,
        'timestamp':timestamp,
        'v':v,
        'sign':sign
        }
url = 'http://gw.api.taobao.com/router/rest'

response = requests.get(url, )
print(response.content)
